package com.hsav.kcxb.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.hsav.kcxb.adapter.common.MyListBaseAdapter;
import com.hsav.kcxb.adapter.manager.CloudManager;
import com.hsav.kcxb.adapter.manager.CollectionManager;
import com.hsav.kcxb.bean.FileBean;

import java.util.ArrayList;

public class CloudListActivity extends Activity {

    private ListView mListView;
    private ArrayList<FileBean> mFileBeanList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cloud_list);
        initView();
    }

    private void initView() {
        TextView titleTx = (TextView)findViewById(R.id.tv_top_title);
        ImageView backImg = (ImageView)findViewById(R.id.iv_top_back);
        titleTx.setText("云点盘");
        backImg.setVisibility(View.VISIBLE);
        initOtherView();
        initData();
        mListView = (ListView)findViewById(R.id.listview_collection);
        CloudManager collectionManager = new CloudManager(mFileBeanList,R.layout.item_file_view);
        MyListBaseAdapter myListBaseAdapter = new MyListBaseAdapter(this,collectionManager);
        mListView.setAdapter(myListBaseAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
                FileBean fileBean = mFileBeanList.get(pos);
                Intent intent = new Intent(CloudListActivity.this,FileDetailActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("file",fileBean);
                intent.putExtras(bundle);
                CloudListActivity.this.startActivity(intent);
            }
        });

    }

    private void initOtherView() {
        TextView passFileTx = (TextView)findViewById(R.id.tx_pass_file);
        TextView showProcessTx = (TextView)findViewById(R.id.tx_show_process);
        passFileTx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        showProcessTx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }

    private void initData() {
        mFileBeanList = new ArrayList<FileBean>();
        for(int i=0;i<20;i++){
            FileBean fileBean = new FileBean("文件"+i,"date"+i,i,"详细");
            mFileBeanList.add(fileBean);
        }
    }
}
